//----------------------------------------------------------------------------
//  ,-.
// /_\___ ,   CA Framework
// '  ___\    (C) Riccardo Capra - http://riccar.do
//  //   \\
//----------------------------------------------------------------------------
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------

#ifndef NJ_RAND_UINT_INLINE_H
#	define NJ_RAND_UINT_INLINE_H

	//----------------------------------------------------------------------------
	template<typename tGenerator>
	inline NjRandUint<tGenerator>::NjRandUint()
	{
		SetMinMax(0, Generator::MAX_RAND);
	}
	//----------------------------------------------------------------------------
	template<typename tGenerator>
	inline NjRandUint<tGenerator>::NjRandUint(NjUint uMin, NjUint uMax)
	{
		SetMinMax(uMin, uMax);
	}
	//----------------------------------------------------------------------------
	template<typename tGenerator>
	inline NjRandUint<tGenerator>::NjRandUint(NjRandUint const & kCopy)
	:
		m_uMin(kCopy.m_uMin),
		m_uModulo(kCopy.m_uModulo)
	{
	}
	//----------------------------------------------------------------------------
	template<typename tGenerator>
	inline NjRandUint<tGenerator> & NjRandUint<tGenerator>::operator=(NjRandUint const & kCopy)
	{
		m_uMin=kCopy.m_uMin;
		m_uModulo=kCopy.m_uModulo;

		return (*this);
	}
	//----------------------------------------------------------------------------
	template<typename tGenerator>
	inline NjUint NjRandUint<tGenerator>::GetMin() const
	{
		return m_uMin;
	}
	//----------------------------------------------------------------------------
	template<typename tGenerator>
	inline NjUint NjRandUint<tGenerator>::GetMax() const
	{
		return m_uMin+m_uModulo;
	}
	//----------------------------------------------------------------------------
	template<typename tGenerator>
	inline void NjRandUint<tGenerator>::SetMinMax(NjUint uMin, NjUint uMax)
	{
		NJ_ASSERT(uMin<uMax);
		m_uMin=uMin;
		m_uModulo=uMax-uMin;
	}
	//----------------------------------------------------------------------------
	template<typename tGenerator>
	inline void NjRandUint<tGenerator>::SetMin(NjUint uMin)
	{
		NJ_ASSERT(uMin<GetMax());

		m_uModulo+=(m_uMin-uMin);
		m_uMin=uMin;
	}
	//----------------------------------------------------------------------------
	template<typename tGenerator>
	inline void NjRandUint<tGenerator>::SetMax(NjUint uMax)
	{
		NJ_ASSERT(m_uMin<uMax);
		m_uModulo=uMax-m_uMin;
	}
	//----------------------------------------------------------------------------
	template<typename tGenerator>
	inline NjUint NjRandUint<tGenerator>::operator() () const
	{
		return m_uMin+Generator::Next()%m_uModulo;
	}
	//----------------------------------------------------------------------------

#endif // NJ_RAND_UINT_INLINE_H
